import App from './App';
import Login from './components/Login';
import React from 'react';
import Register from './components/Register'
import {Route, BrowserRouter as Router} from 'react-router-dom';


export default class Routes extends React.Component{
	render(){
			let userId = localStorage.getItem("user_id");
			console.log("USERID is", userId)
			if(userId === "" || userId === undefined || userId === null){
				console.log("includes"+ window.location.pathname.includes("register"))
				if(window.location.pathname.includes("register")){
					return(
						<div>
							<Register />
						</div>
					)
				}else{
					return(
						<div>
							<Login />
						</div>
					)
				}
				
			}else{
				return(
				<Router>
			        <div>
			        	<Route exact path="/" component={App}/>
				        <Route path="/login" component={Login} />
				        <Route path="/register" component={Register} />
			        </div>
			    </Router>
			    )
			}
	};
}
